﻿@using SDCloudSolution.SDCloud.Web.Models
@using SDCloudSolution.SDCloud.Web.Utils
@model SDCloudSolution.SDCloud.Web.Models.ModelRun.ModelRunViewModel

@{
    Layout = MVC.Shared.Views._AuthorizedLayout;
    ViewBag.PageTitle = string.Format("#{0} - {1}", Model.ModelRunId, Model.ModelName);
}

@section scripts {
    <script src="~/Scripts/js/libs/require/require.js"></script>
    <script src="~/Scripts/app.js"></script>
    <script src="~/Scripts/sdCloud/model.run.view.js"></script>
}

<div id="model-run-buttons-container">
    <h1 class="page-header">
        <a href="@Url.Action(MVC.ModelRuns.List())">
            <img border="0" src="~/Content/left arrow.png" width="24" height="24"></a>

        #@Model.ModelRunId - @Html.ActionLink(Model.ModelName, MVC.Models.View(Model.ModelId))
    </h1>


    @if (Model.CanStop)
    {
        <form action="@Url.Action(MVC.ModelRuns.Cancel(Model.ModelRunId))" method="POST">
            <button id="stopCurrentRun" type="submit" class="button-error"
                    data-bind="ojComponent: {
                        component: 'ojButton',
                        label: 'Stop',
                        icons: {'start': 'fa fa-stop'}
                        }">
                Stop
            </button>
        </form>
    }
</div>
<p></p>

<div class="oj-flex oj-flex-items-pad oj-panel">
    <div class="oj-flex-item oj-margin oj-sm-12 oj-lg-3 oj-md-4 oj-xl-2">
        <div class="oj-header-border bold">Queued</div>
        <div>
            @Model.QuequedDate
        </div>
    </div>
    <div class="oj-flex-item oj-margin oj-sm-12 oj-lg-3 oj-md-4 oj-xl-2">
        <div class="oj-header-border bold">Status</div>
        <div>
            <span class="label label-@Model.StatusType.ToCssClass()">@Model.StatusTitle</span>
        </div>
    </div>
    <div class="oj-flex-item oj-margin oj-sm-12 oj-lg-3 oj-md-4 oj-xl-2">
        <div class="oj-header-border bold">Elapsed Time</div>
        <div>
            <span>@Model.Duration</span>
        </div>
    </div>
    @if (Model.StatusType == StatusViewModel.Success)
    {
        <div class="oj-flex-item oj-margin oj-sm-12 oj-lg-3 oj-md-4 oj-xl-2">
            <div class="oj-header-border bold">Results</div>
            <div>
                <a href="@Url.Action(MVC.ModelRuns.DownloadAsJson(Model.ModelRunId))" target="_blank">
                    <b>Download as .json</b>
                </a>
            </div>
            <div>
                <a href="@Url.Action(MVC.ModelRuns.DownloadAsCsv(Model.ModelRunId))" target="_blank">
                    <b>Download as .csv</b>
                </a>
            </div>
        </div>
    }
</div>

<h3>Log summary</h3>
<div class="oj-flex oj-flex-items-pad oj-panel">
    LOGS IN PROGRESS
</div>
